<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>table-隔行换色</title>
    <style>

        .box{
            width: 100px;
            height: 100px;
            background-color: green;
            animation-name: test;
            animation-duration: 4s;
        }
        table,td,th{
            border: 1px solid;
        }
        table{
            border-collapse: collapse;
            width: 400px;

        }
        tbody tr:nth-child(odd){
            background-color: gray;
        }

        @keyframes test {
            from {
                background-color: red;
            }
            to{
                background-color: green;
            }

        }
    </style>
</head>
<body>
<div class="box"></div>
<table>
    <thead>
       <tr>
           <th>编号</th>
           <th>姓名</th>
           <th>年龄</th>
       </tr>
    </thead>
    <tbody>
       <tr>
           <td>1</td>
           <td>M</td>
           <td>12</td>
       </tr>
       <tr>
           <td>2</td>
           <td>M</td>
           <td>12</td>
       </tr>
       <tr>
           <td>3</td>
           <td>M</td>
           <td>12</td>
       </tr>
    </tbody>

</table>

</body>
</html>